package it.datagraf.formazione.hellostruts.struts;

import java.util.List;

import it.datagraf.formazione.hellostruts.entity.*;
import it.datagraf.formazione.hellostruts.form.InsertCommentForm;
import it.datagraf.formazione.hellostruts.service.CVServiceInteface;
import it.datagraf.formazione.hellostruts.service.CVserviceImpl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class MoreInfo extends Action{
	
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		InsertCommentForm icf= (InsertCommentForm) form;
		
		CVServiceInteface cvsI= new CVserviceImpl();
		int id_cv=(int)icf.getCommento().getId_cv();
		CurriculumVitae cv= cvsI.find(id_cv);
		request.getSession().setAttribute("cv", cv);
		
		List<Commento> commenti=cvsI.listCommenti(id_cv);
		request.setAttribute("commenti", commenti);
		
		return mapping.findForward("scheda");
	}

}
